<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 了解 -->
      <h2>作用域插槽</h2>
      <!-- 作用域插槽的作用是让父组件插入的内容可以访问子组件的作用域 -->

      <!-- 1. 首先可以在slot标签上面添加自定义属性 -->
      <!-- 2. 给父组件的子组件标签上添加v-slot="slotProps", slotProps是一个对象，变量就在这个对象下面 -->

      <!-- <child v-slot="slotProps"> -->
      <!-- <span>{{ slotProps.count }} - {{ slotProps.name1 }}</span> -->
      <child v-slot="{count, name1}">
        <span>{{ count }} - {{ name1 }}</span>
      </child>
    </div>

    <script src="./lib/Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      const Child = {
        data() {
          return {
            count: 10,
            name: "zhangsan",
          };
        },
        template: `
          <div>child子组件 - <slot :count="count" :name1="name"></slot></div>
        `,
      };

      createApp({
        data() {
          return {};
        },
        components: {
          Child,
        },
      }).mount("#app");
    </script>
  </body>
</html>
